<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>工作代理</title>
<link href="css/table.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="js/jquery-1.4.2.min.js"></script>
<script type="text/javascript" src="js/openwindow.js"></script>
<script src="js/My97DatePicker/WdatePicker.js" type="text/javascript" ></script>
<script type="text/javascript">
function selectUser(val){
		var url="getGrouphome.action?status="+val;
		openWindow(url,700,400);
}
function getOldValue(val){
  var ids=document.getElementById(val+"ids").value;
  var names=document.getElementById(val+"names").value;
    var array="";
  if(ids!=''&&ids!='null'){
  var idarray=ids.split(",");
  var namearray=names.split(",");
  for(var i=0;i<idarray.length;i++){
  		if(i==0){
  			array+="{\"value\":"+idarray[i]+",\"name\":\""+namearray[i]+"\"}";
  		}else{
  	      	array+=",{\"value\":"+idarray[i]+",\"name\":\""+namearray[i]+"\"}";
  	   } 
  }
  }
  return array;
}

function setValue(value,val){
  var arr = eval(value);
  var names = "";
  var ids = "";
  for(i=0;i<arr.length;i++){
    ids =  ids + "," + arr[i].value;
    names = names + "," + arr[i].name;
  }
  if(names.length>0){
    names = names.substring(1);
    ids =  ids.substring(1);
  }
  document.getElementById(val+"names").value=names;
  document.getElementById(val+"ids").value=ids;
}

function saveTaskSet(){
	var snames = $("#snames").val()
	var startDate=$("#startDate").val();
	var endDate=$("#endDate").val();
	if(snames==''||snames=='null'){
		alert("请选择人员！");
		return;
	}
	if($.trim(startDate)==''||$.trim(startDate)=='null'){
		alert("开始时间不能为空！");
		return;
	}
	if($.trim(endDate)==''||$.trim(endDate)=='null'){
		alert("结束时间不能为空！");
		return;
	}
	$.post("saveTaskSet.action",$("form").serialize(),function(data){
		if(data=='success'){
		alert("操作成功！");
		window.close();
		window.opener.location="taskSetList.action";
		}else{
		alert("操作失败！");
		}
	});
	
}

</script>
</head>
<body>
<table align="center" border="0" cellpadding="0" cellspacing="0" width="98%">
  <tbody>
  <tr>
    <td style="background: url('image/wsoa_window_002.gif');" width="1"></td>
    <td style="background: url('image/wsoa_window_002.gif');"><table border="0" cellpadding="0" cellspacing="0">
      <tbody><tr>
        <td align="center" style="background: url('image/wsoa_window_002.gif');" width="10"><img src="image/center_19.gif"></td>
        <td align="center" style="background: url('image/wsoa_window_002.gif');"></td>
        <td></td>
        </tr>
    </tbody>
    </table></td>
    <td style="background: url('image/wsoa_window_002.gif');" width="1"></td>
  </tr>
  <tr>
    <td style="background: url('image/wsoa_window_010.gif');"  width="1">&nbsp;</td>
    <td>
		<form action="" method="post" name="taskSetSaveForm">
		<table class="table5" style="width:100%;margin:10px 0px 10px 0px;" align="center">
		<tr>
			<td align="right" class="table5 bgcolor5 ">代理人</td>
		<td class="table5 " colspan="3">
		<textarea readonly="readonly" id="snames" name="taskreport.selectName" style="width:95%;height:40px;">${names}</textarea>
		<input type="hidden" id="sids" name="selectUserId" value="${users}">
		  <br><a href="javascript:selectUser('s')">添加代理人</a>
		</td>
		</tr>
		<tr>
		<td align="right" class="table5 bgcolor5 ">开始时间</td>
		<td class="table5 ">
		<input type="text" id="startDate"  class="Wdate" readonly="readonly"
		onclick="WdatePicker({maxDate:'#F{$dp.$D(\'endDate\',{d:-0});}'})" name="taskreport.startDate" value="${taskreport.startDate}">
		</td>
		<td align="right" class="table5 bgcolor5 ">结束时间</td>
		<td class="table5 ">
		<input type="text" id="endDate"  class="Wdate" readonly="readonly"
		onclick="WdatePicker({minDate:'#F{$dp.$D(\'startDate\',{d:0});}'})" name="taskreport.endDate" value="${taskreport.endDate}">
		</td>
		</tr>
		<tr>
			<td colspan="4" align="center"><input class="button_02" value="提交" type="button" onclick="saveTaskSet()" >&nbsp;<input type="button" class="button_02" value="取消" onclick="window.close()"> </td>
		</tr>
		</table>
	</form>
	<font style="font-size: 12px">*注：设定人员，指可以代理当前用户操作事务</font>
    </td>
<td style="background: url('image/wsoa_window_006.gif');"  width="1">&nbsp;</td></tr>
  <tr>
    <td height="1" width="1"><img src="image/wsoa_window_009.gif" height="16" width="14"></td>
    <td style="background: url('image/wsoa_window_008.gif');" height="1"></td>
    <td height="1" width="1"><img src="image/wsoa_window_007.gif" height="16" width="12"></td>
  </tr>
</tbody>
</table>

</body>
</html>